<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/padrao.xhtml">
	<ui:define name="content">
		<h:form id="formUsuarioHome" style="whidt:100%;">

			<p:messages id="messages" autoUpdate="true" closable="true"  />  
			<p:panel header="Cadastro de Usuarios" style="whidt:700px;">
				<h:panelGrid columns="6" id="painel" width="700">

					<h:outputText value="Nome"/>
					<p:inputText id="usuarioNome" size="30"
						value="#{usuarioHome.usuario.nome}"
						title="informe o nome do usuario" 
						required="true" requiredMessage="o nome deve ser informada"
						label="informe o nome informado" maxlength="60"/>
						<p:tooltip for="usuarioNome" showEvent="focus" hideEvent="blur" />
						
					<h:outputText value="Status" />
						<p:selectOneMenu value="#{usuarioHome.status.id}"
							required="true" requiredMessage="o status deve ser informado">
							<f:selectItem itemLabel="Selecione o status" itemValue=""
								id="status" />
							<f:selectItems value="#{usuarioHome.listStatus}" var="sta"
								itemLabel="#{sta.nome}" itemValue="#{sta.id}" />
						</p:selectOneMenu>
						<p:tooltip for="status" showEvent="focus" hideEvent="blur" />
						
					<h:outputText value="CPF"/>
					<p:inputText id="usuarioCpf" size="11"
						value="#{usuarioHome.usuario.cpf}"
						title="informe o cpf do usuario" 
						required="true" requiredMessage="o cpf deve ser informada"
						label="informe o cpf informado" maxlength="11"/>
						<p:tooltip for="usuarioCpf" showEvent="focus" hideEvent="blur" />

					<h:outputText value="Senha"/>
					<p:password id="usuarioSenha" size="20"
						value="#{usuarioHome.usuario.senha}"
						title="informe a senha do usuario" 
						required="true" requiredMessage="a senha deve ser informada"
						label="informe a senha informado" maxlength="30"/>
						<p:tooltip for="usuarioSenha" showEvent="focus" hideEvent="blur" />

					<h:outputText value="E-mail"/>
					<p:inputText id="usuarioEmail" size="30"
						value="#{usuarioHome.usuario.email}"
						title="informe o email do usuario" 
						required="true" requiredMessage="o email deve ser informada"
						label="informe o email informado" maxlength="60"/>
						<p:tooltip for="usuarioEmail" showEvent="focus" hideEvent="blur" />	
					
	
				</h:panelGrid>
			</p:panel>
					<p:commandButton value="Salvar" action="#{usuarioHome.save}"
						update="painelLista,painel" />
						
				<p:dataTable var="listUsuarios" id="painelLista"
					value="#{usuarioHome.usuarios}" paginator="true" rows="5"
					style="max-width: 100%; min-width: 100%"
				emptyMessage="Nenhum registro.">

				<p:column style="max-width: 20%; min-width: 20%; ">
					<f:facet name="header" width="20%">
						<h:outputText value="CPF" />
					</f:facet>
						<h:outputText value="#{listUsuarios.cpf}" />
					</p:column>

					<p:column
						style="max-width: 450px; min-width: 450px; overflow: hidden">
						<f:facet name="header">
							<h:outputText value="Nome" width="95%" />
						</f:facet>
						<h:outputText value="#{listUsuarios.cpf}" />
					</p:column>


					<p:column width="15%">
						<p:commandButton title="Editar" update="painel" immediate="true"
							action="#{usuarioHome.edit}" ajax="false"
							icon="ui-icon-folder-open">
							<f:setPropertyActionListener target="#{usuarioHome.selected}"
								value="#{listUsuarios}" />
						</p:commandButton>
					</p:column>

					<p:column width="15%">
						<p:commandButton title="Excluir" update="painel" immediate="true"
							action="#{usuarioHome.remove}" ajax="false"
							icon="ui-icon-trash">
							<f:setPropertyActionListener target="#{usuarioHome.selected}"
								value="#{listUsuarios}" />
						</p:commandButton>
					</p:column>

				</p:dataTable>

		</h:form>

	</ui:define>
</ui:composition>
